package incubator.toreinar;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class TestComboBox {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(500,500);
		
		JPanel contentPane = new JPanel(new BorderLayout());
		frame.setContentPane(contentPane);
		
		String[] menuImages = {
				"/resource/image/menu/freePlace.png",
				"/resource/image/menu/placeNode.png",
				"/resource/image/menu/select.png"
		};
		
		
		JPanel buttonPanel = new JPanel();
		for (int i = 0; i < menuImages.length; i++) {
			URL url = TestComboBox.class.getResource(menuImages[i]);
			
			JButton button = new JButton(new ImageIcon(url));
			button.setPreferredSize(new Dimension(50, 50));
			
			buttonPanel.add(button);
		}
			
		
		contentPane.add(buttonPanel, BorderLayout.PAGE_START);
		
		
		
		String[] dropDownImages = {
				"/resource/image/dropdown/60deg.png",
				"/resource/image/dropdown/5kant.png",
		};
	
		String[] imageTexts = {
				"60deg",
				"5 Kant",
		};
		
		
		/*
		 * Med String[] imagePaths som argument
		 */
		ImageComboBox comboBox2 = new ImageComboBox(dropDownImages, imageTexts);
		comboBox2.setName("ComboBox 2");
		comboBox2.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				System.out.println(((JComboBox)arg0.getSource()).getName());
				System.out.println(((JComboBox)arg0.getSource()).getSelectedItem());
			}
			
		});
		
		JPanel comboPanel = new JPanel();
		comboPanel.add(comboBox2);
		
		contentPane.add(comboPanel, BorderLayout.CENTER);
//		contentPane.add(new GridController(null));
		
		frame.setVisible(true);

	}

}
